﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using OrganizedIN.DAL;
using OrganizedIN.BAL;
using OrganizedIN.BussinessServices;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;
using OrganizedIN.BAL.Common;

namespace OrganizedIN.MediaIntrest
{
    public partial class DeleteMedia : System.Web.UI.Page
    {
        BLL objbll = new BLL();
        DateTime dt = DateTime.Now;
         public string  strUserName;

        protected void Page_Load(object sender, EventArgs e)
        {
            lblTodayDate.Text = String.Format("{0:D}", dt);
            strUserName = Session["UserID"].ToString();
            if (!IsPostBack)
            {
                BindGrid(strUserName);
            }
            
        }

        public void BindGrid(string strUserName)
        {
            DataSet ds = objbll.MediaFetch(strUserName);
            if (ds.Tables[0].Rows.Count > 0)
            {
                gvDocList.DataSource =ds.Tables[0];
                gvDocList.DataBind();
            }
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                string strIDs = "";
                int count = 0;

                for (int i = 0; i < gvDocList.Rows.Count; i++)
                {
                    CheckBox chk = (CheckBox)gvDocList.Rows[i].Cells[0].FindControl("chkID");

                    if (chk != null)
                    {
                        if (chk.Checked)
                        {
                            strIDs = strIDs + gvDocList.Rows[i].Cells[1].Text;
                            objbll.MediaDelete(strIDs);

                            count++;
                        }
                    }
                }                   

                BindGrid(strUserName);

            }
            catch (Exception ex)
            {
            }
        }

        


    }
}
